/****************************************************
	文件：ActionBase.cs
	作者：林文豪
	日期：2021/03/25 22:29:03
	功能：Noting
*****************************************************/
using System;
using System.Collections.Generic;
using MyGame.Character;
using MyGame.Global;

namespace MyGame.AI.GOAP {
    public abstract class ActionBase : IAction {
        public Action<bool> OnFinish;

        protected Enemy  _Owner;

        public readonly GoapActionData ExcelData;
        public readonly bool   CanInterrupt;

        public ActionBase(GoapActionData excelData, Enemy owner) {
            ExcelData = excelData;
            _Owner    = owner;
        }
        public abstract void   FrameFunc();
        public abstract string GetAnimationName();
        // TODO : 此方法需要用一定的算法在进行计算
        public abstract float               GetCost();

        public GoapCondition GetEffects() {
            return ExcelData.Effect == null ? null : GoapFactory.Instance.GenerateCondition(ExcelData.Effect);
        }
        public GoapCondition GetPreconditions() {
            return ExcelData.Precondition == null ? null : GoapFactory.Instance.GenerateCondition(ExcelData.Precondition);
        }

        public string GetNodeName() {
            return ExcelData.ActionType.ToString();
        }
        public bool Equals(IAction other) {
            return this.ExcelData.ActionType.ToString() == other.GetNodeName();
        }
    }
}

